package myJs.detailInfo

import myJs.I18n
import myJs.Implicits._
import myJs.myPkg._
import myJs.myPkg.jquery._
import myJs.tool.Tool
import org.scalajs.dom.ext.Ajax
import org.scalajs.dom.{Element, Event, document}
import scalatags.Text.all._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.scalajs.js
import scala.scalajs.js.Dynamic.{global => g}
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}

/** Created by yz on 11/5/2020
  */
@JSExportTopLevel("DetailInfo")
object DetailInfo {

  val mummerId = "mummer"
  val tableId = "table"

  @JSExport("init")
  def init = {
    I18n.initialize()
    BioSampleCp(id = getId).renderIntoDOM(document.getElementById("bioSample"))
    AssemblyCp(id = getId).renderIntoDOM(document.getElementById("assembly"))
    CoverCp(id = getId).renderIntoDOM(document.getElementById("cover"))
    SnpCp(id = getId).renderIntoDOM(document.getElementById("snp"))
    IndelCp(id = getId).renderIntoDOM(document.getElementById("inDel"))
    SvCp(id = getId).renderIntoDOM(document.getElementById("sv"))
    SeqCp(id = getId).renderIntoDOM(document.getElementById("seq"))
    if (List("SAMN19960505", "SAMEA1523368").contains(getId)) {
      $(s"#${mummerId}").hide()
    }
    registerEvent
  }

  def registerEvent = {
    $(".quick-nav .quick-nav-trigger").on(
      "mouseenter",
      (y: Element, e: Event) =>
        (
          $(y).parent().addClass("nav-is-visible")
        )
    )
    $("nav.quick-nav").on(
      "mouseleave",
      (y: Element, e: Event) =>
        (
          $(y).removeClass("nav-is-visible")
        )
    )
  }

  def getId = {
    g.id.toString
  }

}
